<?php
if(!isset($_SESSION)){session_start();} 
require_once('../../Connections/Admin.php'); ?>

<?php 
if(isset($_GET['token'])){
	$token = $_GET['token'];
	mysql_select_db($database_Admin, $Admin);
	$consulta = mysql_query("SELECT userID FROM users WHERE token='".$token."'", $Admin);
	$n= mysql_num_rows($consulta);
	if($n!=0){?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Nueva Contraseña</title>
<link href="../../css/AdminIndex.css" rel="stylesheet" type="text/css">
<script src="../../SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<link href="../../SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
</head>

<body>
<form action="procPass.php" method="post" name="NewPass" id="NewPass">
<table border="2" cellpadding="5">
  <tr>
    <th nowrap scope="row">Nueva Contraseña: </th>
    <td><input type="password" name="pass1" id="pass1" required></td>
  </tr>
  <tr>
    <th nowrap scope="row">Confirmar contraseña:</th>
    <td><span id="spryconfirm1">
      <input type="password" name="password1" id="password1" required><br>
<span class="confirmInvalidMsg">Las contraseñas no coindicen.</span></span></td>
  </tr>
  <tr>
    <th scope="row">&nbsp;</th>
    <td><input type="submit" name="button" id="button" value="Guardar">
    <input type="hidden" value="cambiar" name="compro">
    <input type="hidden" name="token" value="<?php echo $token;?>"> </td>
  </tr>
</table>
<p></p>
</form>
<script type="text/javascript">
var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "pass1", {isRequired:false, validateOn:["change"]});
</script>
</body>
</html>
<?php }else{?>
	<script>function errorToken(){alert("Token invalido.");}
	errorToken();
    </script>
    
    <meta http-equiv="refresh" content="0;url=../index.php">
	<?php }
}else{echo '
	<script>function errorToken(){alert("Acceso denegado.");}
	errorToken();
    </script>
    
    <meta http-equiv="refresh" content="0;url=../index.php">
	';} ?>